package com.wei.web.middleware.httpfilter.utils;


import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.servlet.config.annotation.CorsRegistration;

import java.util.*;

/**
 * @author Chuanding.Si
 * @date 2021/7/28 2:40 PM
 */
public class ZvaCorsRegistry {
    private final List<CorsRegistration> registrations = new ArrayList();

    public ZvaCorsRegistry() {
    }


    public CorsRegistration addMapping(String pathPattern) {
        CorsRegistration registration = new ZvaCorsRegistration(pathPattern);
        this.registrations.add(registration);
        return registration;
    }
    public Map<String, CorsConfiguration> getCorsConfigurations() {
        Map<String, CorsConfiguration> configs = new LinkedHashMap(this.registrations.size());
        Iterator var2 = this.registrations.iterator();

        while(var2.hasNext()) {
            ZvaCorsRegistration registration = (ZvaCorsRegistration)var2.next();
            configs.put(registration.getPathPattern(), registration.getCorsConfiguration());
        }

        return configs;
    }
}
